package io.demo_6_序列化;

import java.io.Serializable;

public class Stu implements Serializable{
    //防止序列化后，类升级，导致版本号更新，从而在反序列化时抛出异常。
    static final long serialVersionUID=1;
    int id;
    String name;
    //静态属性：不参与序列化
    static int age;

    int sal;

    //瞬时属性:不参与序列化
    transient double height;

    public Stu(int id, String name,double height) {
        this.id = id;
        this.name = name;
        this.height = height;
    }

    @Override
    public String toString() {
        return "Stu{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", height=" + height +
                '}';
    }
}
